home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / tcp_ip / os2 / pmnos11s / udpdump.c < prev    next >
C/C++ Source or Header  |  1993-07-30  |  1KB  |  64 lines

  1. /* UDP packet tracing
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  */
  4. /* Mods by PA0GRI */
  5. #include <stdio.h>
  6. #include "global.h"
  7. #include "mbuf.h"
  8. #include "netuser.h"
  9. #include "internet.h"
  10. #include "udp.h"
  11. #include "ip.h"
  12. #include "socket.h"
  13. #include "trace.h"
  14.  
  15. void rwho_dump __ARGS((struct iface *ip,struct mbuf **bpp));
  16.  
  17. /* Dump a UDP header */
  18. void
  19. udp_dump(ip,bpp,source,dest,check)
  20. struct iface  *ip;
  21. struct mbuf **bpp;
  22. int32 source,dest;
  23. int check;        /* If 0, bypass checksum verify */
  24. {
  25.     struct udp udp;
  26.     struct pseudo_header ph;
  27.     int16 csum;
  28.  
  29.     if(bpp == NULLBUFP || *bpp == NULLBUF)
  30.         return;
  31.  
  32.     prtTrace(ip,"UDP:");
  33.  
  34.     /* Compute checksum */
  35.     ph.source = source;
  36.     ph.dest = dest;
  37.     ph.protocol = UDP_PTCL;
  38.     ph.length = len_p(*bpp);
  39.     if((csum = cksum(&ph,*bpp,ph.length)) == 0)
  40.         check = 0;    /* No checksum error */
  41.  
  42.     ntohudp(&udp,bpp);
  43.  
  44.     prtTrace(ip," len %u",udp.length);
  45.     prtTrace(ip," %u->%u",udp.source,udp.dest);
  46.     if(udp.length > UDPHDR)
  47.         prtTrace(ip," Data %u",udp.length - UDPHDR);
  48.     if(udp.checksum == 0)
  49.         check = 0;
  50.     if(check)
  51.         prtTrace(ip," CHECKSUM ERROR (%u)",csum);
  52.  
  53.     prtTrace(ip, "\n");
  54.  
  55.     switch(udp.dest){
  56.     case IPPORT_RIP:
  57.         rip_dump(ip,bpp);
  58.     case IPPORT_RWHO:
  59.         rwho_dump(ip,bpp);
  60.     }
  61.  
  62. }
  63.  
  64.